package com.game.modular.game.act.battle;

import com.game.comment.util.JwtUtils;
import com.game.modular.game.act.battle.vo.BattleVo;
import com.game.modular.game.battle.info.roundInfo.domain.PvpBattleRoundInfo;
import com.game.modular.game.battle.info.roundInfo.domain.PvpBattleStatisticsInfo;
import com.game.modular.game.battle.info.roundInfo.PvpBattleRoundInfoServiceImpl;
import com.game.modular.game.battle.info.roundInfo.PvpBattleStatisticsInfoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import com.game.comment.core.ResponseResult;

import java.util.List;


/**
 * PvP玩家战斗信息(PvpMessageDto)表服务控制层
 *
 * @author cxy
 * @since 2024-08-12 16:34:59
 */
@Api(tags = "PvP玩家战斗信息)")
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("/pvpMessageAct")
public class PvpMessageAction {
    private final PvpBattleRoundInfoServiceImpl pvpBattleRoundInfoServiceImpl;
    private PvpBattleStatisticsInfoServiceImpl pvpBattleStatisticsInfoService;
    //////////////////////////////////////////////////////////////////////////////////////////////////////    战斗统计
    @ApiOperation("当前局内战斗信息")
    @PostMapping("/pvpBattleStatisticsInfoList")
    public ResponseResult<List<PvpBattleStatisticsInfo>> pvpBattleStatisticsInfoList(
            @RequestHeader String token
    ) {
        return ResponseResult.success(pvpBattleStatisticsInfoService.battleStatisticsInfoList(JwtUtils.getPlayerId(token)));
    }

    @ApiOperation("收藏当前局内战斗信息")
    @PostMapping("/collectionPvpBattleStatisticsInfoList")
    public ResponseResult<?> collectionPvpBattleStatisticsInfoList(
            @Valid @RequestBody BattleVo.PvpMessageVo.Base param
    ) {
        pvpBattleStatisticsInfoService.collection(param.getBattleId());
        return ResponseResult.success("收藏当前局内战斗信息成功");
    }

    @ApiOperation("已读当前局内战斗信息")
    @PostMapping("/readCurrentIntraBureauCombatInformation")
    public ResponseResult<?> readCurrentIntraBureauCombatInformation(
            @Valid @RequestBody BattleVo.PvpMessageVo.Base param
    ) {
        pvpBattleStatisticsInfoService.readCurrentIntraBureauCombatInformation(param.getBattleId());
        return ResponseResult.success("收藏当前局内战斗信息成功");
    }

    //////////////////////////////////////////////////////////////////////////////////////////////////////    战斗回访
    @ApiOperation("战斗回放")
    @PostMapping("/battleReplay")
    public ResponseResult<PvpBattleRoundInfo> battleReplay(
            @Valid @RequestBody BattleVo.PvpMessageVo.Base param
    ) {
        return ResponseResult.success(pvpBattleRoundInfoServiceImpl.getById(param.getBattleId()));
    }

    @ApiOperation("收藏战斗回放")
    @PostMapping("/collectionBattleReplay")
    public ResponseResult<?> collectionBattleReplay(
            @Valid @RequestBody BattleVo.PvpMessageVo.Base param
    ) {
        pvpBattleRoundInfoServiceImpl.collectionBattleReplay(param.getBattleId());
        return ResponseResult.success("收藏战斗回放成功");
    }
}
